import requests
# 价格动态
url='https://icps.suning.com/icps-web/getVarnishAllPriceNoCache/000000011715217902,000000011657719979,000000010591170237_759_7590199_0000000000,0000000000,0000000000_1_getClusterPrice.jsonp?callback=getClusterPrice'
# url='https://product.suning.com/0000000000/11715217902.html?utm_source=union&utm_medium=005007&adtype=5&utm_campaign=b760b4de-1865-4485-b475-f30f67f5b9f2&union_place=un'
response = requests.get(url)
# print(response.text)
import execjs
# jsenv = execjs.get().name

ctx = execjs.compile('function getClusterPrice(a){return a;};')
e = ctx.eval(response.text.replace(';',''))  # 可以直接执行JS代码
# # e = execjs.eval(response.text.replace(';',''))
print(len(e))

#!/usr/bin/env python3
# BeautifulSoup4简介
import time

def selen(url):
    from selenium.webdriver.chrome.options import Options
    from selenium import webdriver
    chrome_opt = Options()      # 创建参数设置对象.
    # chrome_opt.add_argument('--headless')   # 无界面化.
    # chrome_opt.add_argument('--disable-gpu')    # 配合上面的无界面化.
    # chrome_opt.add_argument('--window-size=1366,768')   # 设置窗口大小, 窗口大小会有影响.
    prefs = {
        'profile.default_content_setting_values' : {
            'images' : 2
        }
    }
    chrome_opt.add_experimental_option('prefs',prefs)
    # 创建Chrome对象并传入设置信息.
    driver = webdriver.Chrome(chrome_options=chrome_opt)

    # driver = webdriver.Chrome()     # 创建Chrome对象.
    driver.implicitly_wait(10) # seconds
    driver.get(url)
    myDynamicElement = driver.find_element_by_xpath('//*[@class="mainprice"]')
    text = driver.page_source
    print(myDynamicElement.text)